using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class GameController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnEnable()
    {
        Facade.Instance.RegistEvent(GameEvent.Scene.ItemScopeEnter, OnHandleItemScopeEnter);
        Facade.Instance.RegistEvent(GameEvent.Scene.ItemScopeExit, OnHandleItemScopeExit);
    }

    private void OnDisable()
    {
        Facade.Instance.UnRegistEvent(GameEvent.Scene.ItemScopeEnter, OnHandleItemScopeEnter);
        Facade.Instance.UnRegistEvent(GameEvent.Scene.ItemScopeExit, OnHandleItemScopeExit);
    }

    [SerializeField]
    private Animation _animationButtnA;

    private object OnHandleItemScopeEnter(object sender)
    {
        UtilAnimation.PlayButtonAnimation(_animationButtnA);
        return null;
    }

    private object OnHandleItemScopeExit(object sender)
    {
        UtilAnimation.StopButtonAnimation(_animationButtnA);
        return null;
    }

    public void OnButtonAClick()
    {
        UtilAnimation.StopButtonAnimation(_animationButtnA);
        Facade.Instance.SendEvent(GameEvent.Input.ButtonAClick, null);
    }

    public void OnButtonBClick()
    {
        Debug.LogError("OnButtonBClick, Player 侦听事件");
        Facade.Instance.SendEvent(GameEvent.Input.ButtonBClick, null);
    }

    public void OnButtonLeftPressDown(BaseEventData eventData)
    {
        Facade.Instance.SendEvent(GameEvent.Input.ButtonLeftPressDown, null);
    }

    public void OnButtonRightPressDown(BaseEventData eventData)
    {
        Facade.Instance.SendEvent(GameEvent.Input.ButtonRightPressDown, null);
    }

    public void OnButtonUpPressDown(BaseEventData eventData)
    {
        Facade.Instance.SendEvent(GameEvent.Input.ButtonUpPressDown, null);
    }

    public void OnButtonDownPressDown(BaseEventData eventData)
    {
        Facade.Instance.SendEvent(GameEvent.Input.ButtonDownPressDown, null);
    }

    public void OnButtonPressUp(BaseEventData eventData)
    {
        Facade.Instance.SendEvent(GameEvent.Input.ButtonPressUp, null);
    }
}
